#coding:utf8
from rest_framework import serializers
from .models import Area

# [{"id":110000,"name":"北京市"},{"id":120000,"name":"天津市"},{"id":130000,"name":"河北省"}
# 这个序列化器 只是 有 id,name
class AreaSerialzier(serializers.ModelSerializer):

    class Meta:
        model = Area
        fields = ['id','name']


class SubsAreaSerializer(serializers.ModelSerializer):

    # 市,区县
    #[Area,Area,Area]
    # s = AreaSerializer(areas,many=True)
    subs = AreaSerialzier(many=True,read_only=True)

    class Meta:
        model = Area
        fields = ['id','name','subs']
